namespace ContosoUniversity.Migrations
{
   using System;
   using System.Data.Entity.Migrations;

   public partial class InitialCreate : DbMigration
   {
      public override void Up()
      {
         CreateTable(
             "dbo.Student",
             c => new
             {
                StudentID = c.Int(nullable: false, identity: true),
                LastName = c.String(),
                FirstMidName = c.String(),
                EnrollmentDate = c.DateTime(nullable: false),
             })
             .PrimaryKey(t => t.StudentID);

         CreateTable(
             "dbo.Enrollment",
             c => new
             {
                EnrollmentID = c.Int(nullable: false, identity: true),
                CourseID = c.Int(nullable: false),
                StudentID = c.Int(nullable: false),
                Grade = c.Int(),
             })
             .PrimaryKey(t => t.EnrollmentID)
             .ForeignKey("dbo.Course", t => t.CourseID, cascadeDelete: true)
             .ForeignKey("dbo.Student", t => t.StudentID, cascadeDelete: true)
             .Index(t => t.CourseID)
             .Index(t => t.StudentID);

         CreateTable(
             "dbo.Course",
             c => new
             {
                CourseID = c.Int(nullable: false),
                Title = c.String(),
                Credits = c.Int(nullable: false),
             })
             .PrimaryKey(t => t.CourseID);

      }

      public override void Down()
      {
         DropIndex("dbo.Enrollment", new[] { "StudentID" });
         DropIndex("dbo.Enrollment", new[] { "CourseID" });
         DropForeignKey("dbo.Enrollment", "StudentID", "dbo.Student");
         DropForeignKey("dbo.Enrollment", "CourseID", "dbo.Course");
         DropTable("dbo.Course");
         DropTable("dbo.Enrollment");
         DropTable("dbo.Student");
      }
   }
}
